//
//  ExpertInterface.m
//  DaJiang
//
//  Created by sally on 16/10/12.
//  Copyright © 2016年 jiniu. All rights reserved.
//

#import "ExpertInterface.h"

@implementation ExpertInterface

- (id)init {
  self = [super initWithPath:@"/pro_user"];
  if (self) {
  }
  return self;
}

#pragma mark - tab1相关
//获取推荐专家列表(首页)
- (void)queryRecommendListWithLocation:(NSString *)location
                                cursor:(NSInteger)cursor
                            completion:(completion_t)completion
                                 error:(error_t)error {
  NSURL *url = CREATE_REAL_URL(self.interfaceURL, @"recommend/list.json");

  NSDictionary *parameters;
  if (cursor > GCursorInit) {
    parameters = @{ @"user_location_name" : location,
                    @"cursor" : @(cursor),
    };
  } else {
    parameters = @{ @"user_location_name" : location,
    };
  }

  netCompletion_t netCompletion = ^(AFHTTPRequestOperation *operation, id responseObject) {
    NSDictionary *resultDict = responseObject;
    if (resultDict) {
      if (completion) {
        NSDictionary *resultObject = [resultDict objectForKey:DicKeyResult];
        NSInteger code = [[resultDict objectForKey:DicKeyErrorCode] integerValue];
        NSString *description = [resultDict objectForKey:DicKeyErrorMsg];
        description = description ? description : @"";
        completion(resultObject, code, description);
      }
    }
  };

  netFailure_t netFailure = ^(AFHTTPRequestOperation *option, NSError *e) {
    if (error) {
      error(e);
    }
  };

  AFHTTPRequestOperationManager *manager = [ApiBase shareInstance].shareManager;
  [manager POST:[url absoluteString] parameters:parameters success:netCompletion failure:netFailure];
}

//获取全部专家列表
- (void)queryAllExpertListWithLocation:(NSString *)location
                                cursor:(NSInteger)cursor
                            completion:(completion_t)completion
                                 error:(error_t)error {
  NSURL *url = CREATE_REAL_URL(self.interfaceURL, @"list_all.json");

  NSDictionary *parameters;
  if (cursor > GCursorInit) {
    parameters = @{ @"pro_user_location_name" : location,
                    @"cursor" : @(cursor),
    };
  } else {
    parameters = @{ @"pro_user_location_name" : location,
    };
  }

  netCompletion_t netCompletion = ^(AFHTTPRequestOperation *operation, id responseObject) {
    NSDictionary *resultDict = responseObject;
    if (resultDict) {
      if (completion) {
        NSDictionary *resultObject = [resultDict objectForKey:DicKeyResult];
        NSInteger code = [[resultDict objectForKey:DicKeyErrorCode] integerValue];
        NSString *description = [resultDict objectForKey:DicKeyErrorMsg];
        description = description ? description : @"";
        completion(resultObject, code, description);
      }
    }
  };

  netFailure_t netFailure = ^(AFHTTPRequestOperation *option, NSError *e) {
    if (error) {
      error(e);
    }
  };

  AFHTTPRequestOperationManager *manager = [ApiBase shareInstance].shareManager;
  [manager POST:[url absoluteString] parameters:parameters success:netCompletion failure:netFailure];
}

//一级分类目录下的全部专家
- (void)queryLevel1AllExpertListWithLocation:(NSString *)location
                                    proIndex:(NSString *)proIndex
                                      cursor:(NSInteger)cursor
                                  completion:(completion_t)completion
                                       error:(error_t)error {
  NSURL *url = CREATE_REAL_URL(self.interfaceURL, @"list_by_index.json");

  NSDictionary *parameters;
  if (cursor > GCursorInit) {
    parameters = @{ @"pro_user_location_name" : location,
                    @"user_pro_index" : proIndex,
                    @"cursor" : @(cursor),
    };
  } else {
    parameters = @{ @"pro_user_location_name" : location,
                    @"user_pro_index" : proIndex,
    };
  }

  netCompletion_t netCompletion = ^(AFHTTPRequestOperation *operation, id responseObject) {
    NSDictionary *resultDict = responseObject;
    if (resultDict) {
      if (completion) {
        NSDictionary *resultObject = [resultDict objectForKey:DicKeyResult];
        NSInteger code = [[resultDict objectForKey:DicKeyErrorCode] integerValue];
        NSString *description = [resultDict objectForKey:DicKeyErrorMsg];
        description = description ? description : @"";
        completion(resultObject, code, description);
      }
    }
  };

  netFailure_t netFailure = ^(AFHTTPRequestOperation *option, NSError *e) {
    if (error) {
      error(e);
    }
  };

  AFHTTPRequestOperationManager *manager = [ApiBase shareInstance].shareManager;
  [manager POST:[url absoluteString] parameters:parameters success:netCompletion failure:netFailure];
}

//二级分类目录下的所有专家
- (void)queryLevel2AllExpertListWithLocation:(NSString *)location
                                    proIndex:(NSString *)proIndex
                                   proIndex2:(NSString *)proIndex2
                                      cursor:(NSInteger)cursor
                                  completion:(completion_t)completion
                                       error:(error_t)error {
  NSURL *url = CREATE_REAL_URL(self.interfaceURL, @"list_by_index2.json");

  NSDictionary *parameters;
  if (cursor > GCursorInit) {
    parameters = @{ @"pro_user_location_name" : location,
                    @"user_pro_index" : proIndex,
                    @"user_pro_index2" : proIndex2,
                    @"cursor" : @(cursor),
    };
  } else {
    parameters = @{ @"pro_user_location_name" : location,
                    @"user_pro_index" : proIndex,
                    @"user_pro_index2" : proIndex2,
    };
  }

  netCompletion_t netCompletion = ^(AFHTTPRequestOperation *operation, id responseObject) {
    NSDictionary *resultDict = responseObject;
    if (resultDict) {
      if (completion) {
        NSDictionary *resultObject = [resultDict objectForKey:DicKeyResult];
        NSInteger code = [[resultDict objectForKey:DicKeyErrorCode] integerValue];
        NSString *description = [resultDict objectForKey:DicKeyErrorMsg];
        description = description ? description : @"";
        completion(resultObject, code, description);
      }
    }
  };

  netFailure_t netFailure = ^(AFHTTPRequestOperation *option, NSError *e) {
    if (error) {
      error(e);
    }
  };

  AFHTTPRequestOperationManager *manager = [ApiBase shareInstance].shareManager;
  [manager POST:[url absoluteString] parameters:parameters success:netCompletion failure:netFailure];
}

//专家排序
- (void)sortExpertListWithLocation:(NSString *)location
                          proIndex:(NSString *)proIndex
                         proIndex2:(NSString *)proIndex2
                              page:(NSInteger)page
                              type:(ExpertSort_Type)type
                        completion:(completion_t)completion
                             error:(error_t)error {
  NSURL *url;
  if (type == ExpertSort_MeetCount) { //约见次数排序
    url = CREATE_REAL_URL(self.interfaceURL, @"list_by_index2/sort_by_consulting_count.json");
  } else { //评分排序
    url = CREATE_REAL_URL(self.interfaceURL, @"list_by_index2/sort_by_consulting_value.json");
  }

  NSDictionary *parameters;
  if (proIndex.length > 0 && proIndex2.length > 0) { //二级分类目录下的所有专家
    parameters = @{ @"pro_user_location_name" : location,
                    @"user_pro_index" : proIndex,
                    @"user_pro_index2" : proIndex2,
                    @"order" : @"desc",
                    @"page" : @(page),
    };
  } else if (proIndex.length > 0 && proIndex2.length < 1) { //一级分类目录下的全部专家
    parameters = @{ @"pro_user_location_name" : location,
                    @"user_pro_index" : proIndex,
                    @"order" : @"desc",
                    @"page" : @(page),
    };
  } else if (proIndex.length < 1) { //获取全部专家列表
    parameters = @{ @"pro_user_location_name" : location,
                    @"order" : @"desc",
                    @"page" : @(page),
    };
  }

  netCompletion_t netCompletion = ^(AFHTTPRequestOperation *operation, id responseObject) {
    NSDictionary *resultDict = responseObject;
    if (resultDict) {
      if (completion) {
        NSDictionary *resultObject = [resultDict objectForKey:DicKeyResult];
        NSInteger code = [[resultDict objectForKey:DicKeyErrorCode] integerValue];
        NSString *description = [resultDict objectForKey:DicKeyErrorMsg];
        description = description ? description : @"";
        completion(resultObject, code, description);
      }
    }
  };

  netFailure_t netFailure = ^(AFHTTPRequestOperation *option, NSError *e) {
    if (error) {
      error(e);
    }
  };

  AFHTTPRequestOperationManager *manager = [ApiBase shareInstance].shareManager;
  [manager POST:[url absoluteString] parameters:parameters success:netCompletion failure:netFailure];
}

//搜索
- (void)searchExpertListWithLocation:(NSString *)location
                             content:(NSString *)content
                          completion:(completion_t)completion
                               error:(error_t)error {
  NSURL *url = CREATE_REAL_URL(self.interfaceURL, @"find.json");

  NSDictionary *parameters = @{ @"pro_user_location_name" : location,
                                @"find_name" : content,
  };

  netCompletion_t netCompletion = ^(AFHTTPRequestOperation *operation, id responseObject) {
    NSDictionary *resultDict = responseObject;
    if (resultDict) {
      if (completion) {
        NSDictionary *resultObject = [resultDict objectForKey:DicKeyResult];
        NSInteger code = [[resultDict objectForKey:DicKeyErrorCode] integerValue];
        NSString *description = [resultDict objectForKey:DicKeyErrorMsg];
        description = description ? description : @"";
        completion(resultObject, code, description);
      }
    }
  };

  netFailure_t netFailure = ^(AFHTTPRequestOperation *option, NSError *e) {
    if (error) {
      error(e);
    }
  };

  AFHTTPRequestOperationManager *manager = [ApiBase shareInstance].shareManager;
  [manager POST:[url absoluteString] parameters:parameters success:netCompletion failure:netFailure];
}

#pragma mark - 专家详情相关
//获取专家详情
- (void)queryExpertDetailWithProUid:(NSInteger)proUid
                         completion:(completion_t)completion
                              error:(error_t)error {
  NSURL *url = CREATE_REAL_URL(self.interfaceURL, @"show.json");
  UserModel *userModel = [[CacheManager shareInstance] getLastLoginAccount];

  NSDictionary *parameters = @{ @"pro_uid" : @(proUid),
                                @"uid" : @(userModel.uid),
  };

  netCompletion_t netCompletion = ^(AFHTTPRequestOperation *operation, id responseObject) {
    NSDictionary *resultDict = responseObject;
    if (resultDict) {
      if (completion) {
        NSDictionary *resultObject = [resultDict objectForKey:DicKeyResult];
        NSInteger code = [[resultDict objectForKey:DicKeyErrorCode] integerValue];
        NSString *description = [resultDict objectForKey:DicKeyErrorMsg];
        description = description ? description : @"";
        completion(resultObject, code, description);
      }
    }
  };

  netFailure_t netFailure = ^(AFHTTPRequestOperation *option, NSError *e) {
    if (error) {
      error(e);
    }
  };

  AFHTTPRequestOperationManager *manager = [ApiBase shareInstance].shareManager;
  [manager POST:[url absoluteString] parameters:parameters success:netCompletion failure:netFailure];
}

//查看更多评论
- (void)queryCommentListWithProUid:(NSInteger)proUid
                            cursor:(NSInteger)cursor
                        completion:(completion_t)completion
                             error:(error_t)error {
  NSURL *url = CREATE_REAL_URL(self.interfaceURL, @"comment/list.json");

  NSDictionary *parameters;
  if (cursor > GCursorInit) {
    parameters = @{ @"pro_uid" : @(proUid),
                    @"cursor" : @(cursor),
    };
  } else {
    parameters = @{ @"pro_uid" : @(proUid),
    };
  }

  netCompletion_t netCompletion = ^(AFHTTPRequestOperation *operation, id responseObject) {
    NSDictionary *resultDict = responseObject;
    if (resultDict) {
      if (completion) {
        NSDictionary *resultObject = [resultDict objectForKey:DicKeyResult];
        NSInteger code = [[resultDict objectForKey:DicKeyErrorCode] integerValue];
        NSString *description = [resultDict objectForKey:DicKeyErrorMsg];
        description = description ? description : @"";
        completion(resultObject, code, description);
      }
    }
  };

  netFailure_t netFailure = ^(AFHTTPRequestOperation *option, NSError *e) {
    if (error) {
      error(e);
    }
  };

  AFHTTPRequestOperationManager *manager = [ApiBase shareInstance].shareManager;
  [manager POST:[url absoluteString] parameters:parameters success:netCompletion failure:netFailure];
}

#pragma mark - 约见接口相关
//专家可约的有空列表
- (void)queryExpertFreeListWithProUid:(NSInteger)proUid
                           completion:(completion_t)completion
                                error:(error_t)error {
  NSURL *url = CREATE_REAL_URL(self.interfaceURL, @"free_time/list_free.json");

  NSDictionary *parameters = @{ @"pro_uid" : @(proUid),
  };

  netCompletion_t netCompletion = ^(AFHTTPRequestOperation *operation, id responseObject) {
    NSDictionary *resultDict = responseObject;
    if (resultDict) {
      if (completion) {
        NSDictionary *resultObject = [resultDict objectForKey:DicKeyResult];
        NSInteger code = [[resultDict objectForKey:DicKeyErrorCode] integerValue];
        NSString *description = [resultDict objectForKey:DicKeyErrorMsg];
        description = description ? description : @"";
        completion(resultObject, code, description);
      }
    }
  };

  netFailure_t netFailure = ^(AFHTTPRequestOperation *option, NSError *e) {
    if (error) {
      error(e);
    }
  };

  AFHTTPRequestOperationManager *manager = [ApiBase shareInstance].shareManager;
  [manager POST:[url absoluteString] parameters:parameters success:netCompletion failure:netFailure];
}

#pragma mark - 我的（用户）相关
//申请成为专家
- (void)applyExpertWithModel:(BecomeExpertModel *)becomeExpertModel
                  completion:(completion_t)completion
                       error:(error_t)error {
  NSURL *url = CREATE_REAL_URL(self.interfaceURL, @"apply.json");
  UserModel *userModel = [[CacheManager shareInstance] getLastLoginAccount];

  NSDictionary *parameters = @{ @"uid" : @(userModel.uid),
                                @"education" : becomeExpertModel.education,
                                @"user_location_name" : becomeExpertModel.loc,
                                @"witness" : becomeExpertModel.witness,
                                @"id_card_pic" : becomeExpertModel.idCardPic,
                                @"qualification_file" : becomeExpertModel.qualificationFile,
                                @"self_desc" : becomeExpertModel.selfDesc,
                                @"user_name" : becomeExpertModel.userName,
                                @"serving_company" : becomeExpertModel.company,
                                @"user_title" : becomeExpertModel.userTitle,
                                @"work_experience" : becomeExpertModel.experience,
                                @"topic_name" : becomeExpertModel.topicName,
                                @"time_length" : becomeExpertModel.timeLength,
                                @"topic_desc" : becomeExpertModel.topicDesc,
                                @"topic_price" : @(becomeExpertModel.topicPrice),
                                @"user_profile_bg_pic" : becomeExpertModel.bgPic,
                                @"user_pro_topic_index" : becomeExpertModel.topicIndex,
                                @"user_pro_topic_index2" : becomeExpertModel.topicIndex2,
                                @"pro_user_email" : becomeExpertModel.userEmail,

  };

  netCompletion_t netCompletion = ^(AFHTTPRequestOperation *operation, id responseObject) {
    NSDictionary *resultDict = responseObject;
    if (resultDict) {
      if (completion) {
        NSDictionary *resultObject = [resultDict objectForKey:DicKeyResult];
        NSInteger code = [[resultDict objectForKey:DicKeyErrorCode] integerValue];
        NSString *description = [resultDict objectForKey:DicKeyErrorMsg];
        description = description ? description : @"";
        completion(resultObject, code, description);
      }
    }
  };

  netFailure_t netFailure = ^(AFHTTPRequestOperation *option, NSError *e) {
    if (error) {
      error(e);
    }
  };

  AFHTTPRequestOperationManager *manager = [ApiBase shareInstance].shareManager;
  [manager POST:[url absoluteString] parameters:parameters success:netCompletion failure:netFailure];
}

//查询申请状态
- (void)queryApplyStatusWithCompletion:(completion_t)completion
                                 error:(error_t)error {
  NSURL *url = CREATE_REAL_URL(self.interfaceURL, @"apply/show.json");
  UserModel *userModel = [[CacheManager shareInstance] getLastLoginAccount];

  NSDictionary *parameters = @{ @"uid" : @(userModel.uid),
  };

  netCompletion_t netCompletion = ^(AFHTTPRequestOperation *operation, id responseObject) {
    NSDictionary *resultDict = responseObject;
    if (resultDict) {
      if (completion) {
        NSDictionary *resultObject = [resultDict objectForKey:DicKeyResult];
        NSInteger code = [[resultDict objectForKey:DicKeyErrorCode] integerValue];
        NSString *description = [resultDict objectForKey:DicKeyErrorMsg];
        description = description ? description : @"";
        completion(resultObject, code, description);
      }
    }
  };

  netFailure_t netFailure = ^(AFHTTPRequestOperation *option, NSError *e) {
    if (error) {
      error(e);
    }
  };

  AFHTTPRequestOperationManager *manager = [ApiBase shareInstance].shareManager;
  [manager POST:[url absoluteString] parameters:parameters success:netCompletion failure:netFailure];
}

#pragma mark - 我的（专家）相关
//约我的人
- (void)queryExpertOrderListWithCursor:(NSInteger)cursor
                                  type:(OrderStatusType)type
                            completion:(completion_t)completion
                                 error:(error_t)error {
  NSURL *url;
  if (type == OrderStatusType_Ing) {
    url = CREATE_REAL_URL(self.interfaceURL, @"my_consulting_list/in_process.json");
  } else if (type == OrderStatusType_End) {
    url = CREATE_REAL_URL(self.interfaceURL, @"my_consulting_list/closed.json");
  }
  UserModel *userModel = [[CacheManager shareInstance] getLastLoginAccount];

  NSDictionary *parameters;
  if (cursor > GCursorInit) {
    parameters = @{ @"pro_uid" : @(userModel.uid),
                    @"cursor" : @(cursor),
    };
  } else {
    parameters = @{ @"pro_uid" : @(userModel.uid),
    };
  }

  netCompletion_t netCompletion = ^(AFHTTPRequestOperation *operation, id responseObject) {
    NSDictionary *resultDict = responseObject;
    if (resultDict) {
      if (completion) {
        NSDictionary *resultObject = [resultDict objectForKey:DicKeyResult];
        NSInteger code = [[resultDict objectForKey:DicKeyErrorCode] integerValue];
        NSString *description = [resultDict objectForKey:DicKeyErrorMsg];
        description = description ? description : @"";
        completion(resultObject, code, description);
      }
    }
  };

  netFailure_t netFailure = ^(AFHTTPRequestOperation *option, NSError *e) {
    if (error) {
      error(e);
    }
  };

  AFHTTPRequestOperationManager *manager = [ApiBase shareInstance].shareManager;
  [manager POST:[url absoluteString] parameters:parameters success:netCompletion failure:netFailure];
}

//提现页面
- (void)queryCashAccountWithCompletion:(completion_t)completion
                                 error:(error_t)error {
  NSURL *url = CREATE_REAL_URL(self.interfaceURL, @"cash_account/show.json");
  UserModel *userModel = [[CacheManager shareInstance] getLastLoginAccount];

  NSDictionary *parameters = @{ @"pro_uid" : @(userModel.uid),
  };

  netCompletion_t netCompletion = ^(AFHTTPRequestOperation *operation, id responseObject) {
    NSDictionary *resultDict = responseObject;
    if (resultDict) {
      if (completion) {
        NSDictionary *resultObject = [resultDict objectForKey:DicKeyResult];
        NSInteger code = [[resultDict objectForKey:DicKeyErrorCode] integerValue];
        NSString *description = [resultDict objectForKey:DicKeyErrorMsg];
        description = description ? description : @"";
        completion(resultObject, code, description);
      }
    }
  };

  netFailure_t netFailure = ^(AFHTTPRequestOperation *option, NSError *e) {
    if (error) {
      error(e);
    }
  };

  AFHTTPRequestOperationManager *manager = [ApiBase shareInstance].shareManager;
  [manager POST:[url absoluteString] parameters:parameters success:netCompletion failure:netFailure];
}

//提现绑定支付宝
- (void)bindAlipayWithAlipay:(NSString *)alipay
                  completion:(completion_t)completion
                       error:(error_t)error {
  NSURL *url = CREATE_REAL_URL(self.interfaceURL, @"bind_alipay.json");
  UserModel *userModel = [[CacheManager shareInstance] getLastLoginAccount];

  NSDictionary *parameters = @{ @"pro_uid" : @(userModel.uid),
                                @"alipay" : alipay,
  };

  netCompletion_t netCompletion = ^(AFHTTPRequestOperation *operation, id responseObject) {
    NSDictionary *resultDict = responseObject;
    if (resultDict) {
      if (completion) {
        NSDictionary *resultObject = [resultDict objectForKey:DicKeyResult];
        NSInteger code = [[resultDict objectForKey:DicKeyErrorCode] integerValue];
        NSString *description = [resultDict objectForKey:DicKeyErrorMsg];
        description = description ? description : @"";
        completion(resultObject, code, description);
      }
    }
  };

  netFailure_t netFailure = ^(AFHTTPRequestOperation *option, NSError *e) {
    if (error) {
      error(e);
    }
  };

  AFHTTPRequestOperationManager *manager = [ApiBase shareInstance].shareManager;
  [manager POST:[url absoluteString] parameters:parameters success:netCompletion failure:netFailure];
}

//提现
- (void)takeCashWithValue:(NSString *)value
               completion:(completion_t)completion
                    error:(error_t)error {
  NSURL *url = CREATE_REAL_URL(self.interfaceURL, @"take_cash.json");
  UserModel *userModel = [[CacheManager shareInstance] getLastLoginAccount];

  NSDictionary *parameters = @{ @"pro_uid" : @(userModel.uid),
                                @"value" : value,
  };

  netCompletion_t netCompletion = ^(AFHTTPRequestOperation *operation, id responseObject) {
    NSDictionary *resultDict = responseObject;
    if (resultDict) {
      if (completion) {
        NSDictionary *resultObject = [resultDict objectForKey:DicKeyResult];
        NSInteger code = [[resultDict objectForKey:DicKeyErrorCode] integerValue];
        NSString *description = [resultDict objectForKey:DicKeyErrorMsg];
        description = description ? description : @"";
        completion(resultObject, code, description);
      }
    }
  };

  netFailure_t netFailure = ^(AFHTTPRequestOperation *option, NSError *e) {
    if (error) {
      error(e);
    }
  };

  AFHTTPRequestOperationManager *manager = [ApiBase shareInstance].shareManager;
  [manager POST:[url absoluteString] parameters:parameters success:netCompletion failure:netFailure];
}

//约见是否开放
- (void)setMeetAvailableWithAvailable:(NSInteger)available
                           completion:(completion_t)completion
                                error:(error_t)error {
  NSURL *url = CREATE_REAL_URL(self.interfaceURL, @"pro_consulting/set_available.json");
  UserModel *userModel = [[CacheManager shareInstance] getLastLoginAccount];

  NSDictionary *parameters = @{ @"pro_uid" : @(userModel.uid),
                                @"available" : @(available),
  };

  netCompletion_t netCompletion = ^(AFHTTPRequestOperation *operation, id responseObject) {
    NSDictionary *resultDict = responseObject;
    if (resultDict) {
      if (completion) {
        NSDictionary *resultObject = [resultDict objectForKey:DicKeyResult];
        NSInteger code = [[resultDict objectForKey:DicKeyErrorCode] integerValue];
        NSString *description = [resultDict objectForKey:DicKeyErrorMsg];
        description = description ? description : @"";
        completion(resultObject, code, description);
      }
    }
  };

  netFailure_t netFailure = ^(AFHTTPRequestOperation *option, NSError *e) {
    if (error) {
      error(e);
    }
  };

  AFHTTPRequestOperationManager *manager = [ApiBase shareInstance].shareManager;
  [manager POST:[url absoluteString] parameters:parameters success:netCompletion failure:netFailure];
}

//管理话题列表
- (void)queryTopicListWithCursor:(NSInteger)cursor
                      completion:(completion_t)completion
                           error:(error_t)error {
  NSURL *url = CREATE_REAL_URL(self.interfaceURL, @"my_pro_topic/list.json");
  UserModel *userModel = [[CacheManager shareInstance] getLastLoginAccount];

  NSDictionary *parameters;
  if (cursor > GCursorInit) {
    parameters = @{ @"pro_uid" : @(userModel.uid),
                    @"cursor" : @(cursor),
    };
  } else {
    parameters = @{ @"pro_uid" : @(userModel.uid),
    };
  }

  netCompletion_t netCompletion = ^(AFHTTPRequestOperation *operation, id responseObject) {
    NSDictionary *resultDict = responseObject;
    if (resultDict) {
      if (completion) {
        NSDictionary *resultObject = [resultDict objectForKey:DicKeyResult];
        NSInteger code = [[resultDict objectForKey:DicKeyErrorCode] integerValue];
        NSString *description = [resultDict objectForKey:DicKeyErrorMsg];
        description = description ? description : @"";
        completion(resultObject, code, description);
      }
    }
  };

  netFailure_t netFailure = ^(AFHTTPRequestOperation *option, NSError *e) {
    if (error) {
      error(e);
    }
  };

  AFHTTPRequestOperationManager *manager = [ApiBase shareInstance].shareManager;
  [manager POST:[url absoluteString] parameters:parameters success:netCompletion failure:netFailure];
}

//专家有空列表
- (void)queryFreeListWithCompletion:(completion_t)completion
                              error:(error_t)error {
  NSURL *url = CREATE_REAL_URL(self.interfaceURL, @"free_time/list.json");
  UserModel *userModel = [[CacheManager shareInstance] getLastLoginAccount];

  NSDictionary *parameters = @{ @"pro_uid" : @(userModel.uid),
  };

  netCompletion_t netCompletion = ^(AFHTTPRequestOperation *operation, id responseObject) {
    NSDictionary *resultDict = responseObject;
    if (resultDict) {
      if (completion) {
        NSDictionary *resultObject = [resultDict objectForKey:DicKeyResult];
        NSInteger code = [[resultDict objectForKey:DicKeyErrorCode] integerValue];
        NSString *description = [resultDict objectForKey:DicKeyErrorMsg];
        description = description ? description : @"";
        completion(resultObject, code, description);
      }
    }
  };

  netFailure_t netFailure = ^(AFHTTPRequestOperation *option, NSError *e) {
    if (error) {
      error(e);
    }
  };

  AFHTTPRequestOperationManager *manager = [ApiBase shareInstance].shareManager;
  [manager POST:[url absoluteString] parameters:parameters success:netCompletion failure:netFailure];
}

//添加有空
- (void)addFreeWithTime:(NSString *)time
               location:(NSString *)location
             completion:(completion_t)completion
                  error:(error_t)error {
  NSURL *url = CREATE_REAL_URL(self.interfaceURL, @"free_time/add.json");
  UserModel *userModel = [[CacheManager shareInstance] getLastLoginAccount];

  NSDictionary *parameters = @{ @"pro_uid" : @(userModel.uid),
                                @"time" : time,
                                @"location" : location,
  };

  netCompletion_t netCompletion = ^(AFHTTPRequestOperation *operation, id responseObject) {
    NSDictionary *resultDict = responseObject;
    if (resultDict) {
      if (completion) {
        NSDictionary *resultObject = [resultDict objectForKey:DicKeyResult];
        NSInteger code = [[resultDict objectForKey:DicKeyErrorCode] integerValue];
        NSString *description = [resultDict objectForKey:DicKeyErrorMsg];
        description = description ? description : @"";
        completion(resultObject, code, description);
      }
    }
  };

  netFailure_t netFailure = ^(AFHTTPRequestOperation *option, NSError *e) {
    if (error) {
      error(e);
    }
  };

  AFHTTPRequestOperationManager *manager = [ApiBase shareInstance].shareManager;
  [manager POST:[url absoluteString] parameters:parameters success:netCompletion failure:netFailure];
}

@end
